<html>

    <?php
    echo $this->render("/common/header.phtml");
    ?>
    <script>
        function updatePriority(id){           
            var baseUrl = <?php echo '"' . $this->doupdatepriority . '"' ?>   
            var text = document.getElementById('priority'+id);  
            text = text.value;             
            var a = baseUrl+"?id="+id+"&priority="+text;         
            ajax.get(a,null,function(f){
                alert(f);
            },null);  
        }
        
        function updateAvatar(id){
            var baseUrl = <?php echo '"' . $this->doupdateavatar . '"' ?>   
            var text = document.getElementById('avatar'+id).value;  
            var a = baseUrl+"?id="+id+"&avatar="+text;
            ajax.get(a,null,function(f){
                alert(f);
            },null);  
        }
        
        function deletes(id){
            var baseUrl = <?php echo '"' . $this->deleteAction . '"' ?>   
            var a = baseUrl+"?id="+id;            
            ajax.get(a,null,function(f){
                alert(f);
            },null);             
        }
    </script>
    <body>
        <?php
        echo $this->render("/common/topMenu.phtml");
        ?>
    <center>
        <div id="tbSite" class="tbsite">
            <form action=<?php echo $this->baseAdd ?> >
                <input type="submit" value="Add New Place" />       
            </form>
        </div>  
        <table border="0px" id="gradient-style" style="width: 100%">
            <?php
            echo "<tr>
                        <th>PlaceId</th>
                        <th>Priority</th>
                        <th>Update priority</th> 
                        <th>Avatar</th>                        
                        <th>UpdateAvatar</th>                        
                        <th>Name</th>
                        <th>Address</th>
                        <th>Update</th>
                        <th>Delete</th>
                      </tr>";
            foreach ($this->data as $item) {

                echo '  <tr> ';
                echo '      <td> ' . $item['id'] . '</td>';
                echo '      <td> <input style="width : 30px" type="text" id=priority' . $item['id'] . ' value=' . $item['priority'] . ' /></td>';
                echo '      <td> <input type="button" onclick="updatePriority(' . $item['id'] . ') " value="Update priority" /></td>';
               
                echo '      <td> <img src="' . $item['avatarLink'] . '" alt="avatar" height="42" width="42"/> </td>';
                echo '      <td> 
                                <input type="text" id=avatar' . $item['id'] . ' style="width : 120px"/> 
                                <input type="button" onclick="updateAvatar(' . $item['id'] . ') " value="Update" style="width : 60px"/>         
                            </td>';
                echo '      <td> ' . $item['name'] . '</td>';
                echo '      <td> ' . $item['address'] . '</td>';
                echo '      <td>';
                echo '          <form action = ' . $this->baseUpdate . '>';
                echo '                  <input type="hidden" name="id" value="' . $item['id'] . '" />';
                echo '                  <input type="submit" value="Update it" />       ';
                echo '          </form>';
                echo '      </td>';
                echo '      <td> <input type="submit" onclick="deletes(' . $item['id'] . ') " value="Delete" /></td>';
                echo '  </tr> ';
            }
            ?>
        </table>

    </div>
    <?php
    echo $this->paginationControl($this->data, 'Sliding', '/user/pagination.phtml');
    ?> 
</center>


</body>

</html>
